import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Test {
    public static void main(String[] args) {
        List<Integer> list=new ArrayList<>();
        list.add(10);
        list.add(20);
        list.add(30);
        Iterator<Integer> iterator= list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        ListIterator<Integer> it=list.listIterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("-------------------------");
        ListIterator<Integer> it2= list.listIterator(list.size());
        while (it2.hasPrevious()){
            System.out.println(it2.previous());
        }
    }
}
